{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1f0cef02-eb9a-4b1d-a2db-6d7f403dbe9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "w= [   11.51226671  -282.51443231   534.2084846    401.73037118\n",
      " -1043.90460259   634.92891045   186.43568421   204.94157943\n",
      "   762.46336088    91.95399832] b= 152.5625670974632\n"
     ]
    }
   ],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "from sklearn.datasets import load_diabetes\n",
    "from sklearn.model_selection import train_test_split\n",
    "x,y=load_diabetes().data,load_diabetes().target\n",
    "x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=8)\n",
    "model =LinearRegression()\n",
    "model.fit(x_train,y_train)\n",
    "print(\"w=\",model.coef_,\"b=\",model.intercept_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ccce2693-1c9b-46b7-b856-9fe49a2abb9f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "模型在测试集上的预测转确率 0.5303801379270054\n",
      "模型在测试集上的预测准确率 0.4593422174874441\n"
     ]
    }
   ],
   "source": [
    "r21=model.score(x_train,y_train)\n",
    "r22=model.score(x_test,y_test)\n",
    "print(\"模型在测试集上的预测转确率\",r21)\n",
    "print(\"模型在测试集上的预测准确率\",r22)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf35b80e-4ed7-46ba-a945-0f77d6a6015c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
